﻿using System;

namespace Microsoft.Xna.Framework.Content
{
	/// <summary>
	/// A manager that constructs and keeps track of type reader objects.
	/// </summary>
    public sealed class ContentTypeReaderManager
    {
        ContentReader _reader;

        internal ContentTypeReaderManager(ContentReader reader)
        {
            _reader = reader;
        }

		/// <summary>
		/// Looks up a reader for the specified type.
		/// </summary>
		/// <param name="targetType">The type the reader will handle.</param>
        public ContentTypeReader GetTypeReader(Type targetType)
        {
            foreach (ContentTypeReader r in _reader.TypeReaders)
            {
                if (targetType == r.TargetType) return r;
            }
            return null;
        }
    }
}